﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.bidsupplyinfo
{
    public partial class Add : Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lcs.BLL.pmtypeinfo pmbll = new BLL.pmtypeinfo();
                DataSet ds = pmbll.GetList("pmid>0");
                ddlmtype.DataSource = ds;
                ddlmtype.DataTextField = "pmtype";
                ddlmtype.DataValueField = "pmid";
                ddlmtype.DataBind();
                Page.DataBind();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (!PageValidate.IsDecimal(txtquota.Text))
            {
                strErr += "配额格式错误！\\n";
            }            
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int mtype =int.Parse(this.ddlmtype.SelectedValue.ToString());
            decimal quota = decimal.Parse(this.txtquota.Text);
            string sidname = this.txtsid.Text;
            int sid = 0;
             if(hfsid.Value!="")sid=int.Parse(hfsid.Value);
             int blevel = int.Parse(this.txtblevel.Text);
             if (sid != 0)
             {
                 lcs.Model.bidsupplyinfo model = new lcs.Model.bidsupplyinfo();
                 model.mtype = mtype;
                 model.quota = quota;
                 model.sid = sid;
                 model.blevel = blevel;
                 model.aid = getaid();
                 lcs.BLL.bidsupplyinfo bll = new lcs.BLL.bidsupplyinfo();
                 if(bll.Add(model)>0)
                 Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "Add.aspx");
                 else
                     Maticsoft.Common.MessageBox.Show(this, "添加失败！");
             }
             else
             {
                 Maticsoft.Common.MessageBox.Show(this, "没有找到供应商！");
             }
        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
